Skip to content

Custom reward addresses for masternodes #83

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: Development
Choose a base branch
from

Conversation

domob1812
Copy link

@domob1812 domob1812 commented Apr 14, 2021

Currently, masternode rewards are paid to the address that holds the collateral. In some situations, this is restrictive, and it would be useful to give masternode owners a choice about where the reward should be paid to (for instance, this will allow easier setup of masternode vaults for improved security).

This set of changes implements a protocol upgrade, which then allows masternodes to (optinally) configure an arbitrary script to which rewards should be paid. Until the upgrade and until a particular masternode owner decides to explicitly opt into this feature, rewards will continue to be paid to the default script (matching the collateral address).

The protocol update itself will be activated at a hard-coded activation time using the fork activation framework from staking vaults. For now, the activation time is set to 2'000'000'000 (i.e. "far away") and will need to be adjusted once we are ready to schedule the fork.

This is #44 rebased and reopened to some changes done to the git branches.

@domob1812 domob1812 force-pushed the custom-reward-address branch from f207367 to 919895e Compare April 28, 2021 14:27
@domob1812 domob1812 force-pushed the custom-reward-address branch 5 times, most recently from 641be27 to cad445b Compare May 18, 2021 11:49
@domob1812 domob1812 force-pushed the custom-reward-address branch 3 times, most recently from f4babcd to 551e72b Compare May 31, 2021 12:56
@domob1812 domob1812 force-pushed the custom-reward-address branch 3 times, most recently from ea6a3b5 to b2d4e5c Compare June 17, 2021 12:44
@domob1812 domob1812 force-pushed the custom-reward-address branch from b2d4e5c to 5a3311b Compare June 29, 2021 12:16
@domob1812 domob1812 force-pushed the custom-reward-address branch 2 times, most recently from 5910359 to 511505f Compare July 7, 2021 13:47
@domob1812 domob1812 force-pushed the custom-reward-address branch 2 times, most recently from c400b74 to 774b715 Compare August 19, 2021 13:51
@domob1812 domob1812 force-pushed the custom-reward-address branch 4 times, most recently from 58c0cd9 to e059323 Compare August 20, 2021 13:33
@domob1812 domob1812 force-pushed the custom-reward-address branch 2 times, most recently from a157b4a to d0fff31 Compare September 9, 2021 09:17
@domob1812 domob1812 force-pushed the custom-reward-address branch 3 times, most recently from 68a38ef to 4e31101 Compare October 14, 2021 11:21
@domob1812 domob1812 force-pushed the custom-reward-address branch 3 times, most recently from 84b987a to 2582ecf Compare November 2, 2021 13:26
@domob1812 domob1812 force-pushed the custom-reward-address branch 5 times, most recently from bebd6ba to c683b9d Compare November 3, 2021 14:18
@domob1812 domob1812 force-pushed the custom-reward-address branch from c683b9d to 29a76bc Compare November 10, 2021 12:52
This adds a new field, CScript rewardScript, to the masternode data
structures.  For now, we just add it, return it from the RPCs, and
set it to the script corresponding to the collateral pubkey on
creation.

We also serialise the new field as part of CMasternode, which is used
e.g. in the on-disk cache, but not the wire protocol (where
CMasternodeBroadcast is used instead).  Thus this change invalidates the
mncache format, but has no other effects on compatibility.

In the future, we will implement a protocol upgrade and also network
fork that will use this new field so masternodes can specify an arbitrary
script to which they want to receive their payments, rather than being
paid always to the collateral address.
Define a new wire protocol version, and for peers that match the
version, send the reward script as explicit part of the masternode
broadcast messages.

Also, if the reward script is not the default value, include it in the
signature message of the broadcast (so that the field is authenticated
by the collateral signature).

Until the protocol version is bumped on the network (which is not yet
the case with this commit), masternodes with non-default reward script
will not be accepted as valid.
Instead of using the collateral pubkey, pay to the declared reward
script of masternodes (and use that to check payments).
This extends the setupmasternode RPC method so that it allows setting
a non-default reward address.  The reward address is an optional sixth
argument following the ip_address.
Use a custom reward address for one of the two masternodes in the
mnoperation.py regtest, verifying that this works.

For the test, we activate the new protocol version on regtest without
any forking logic.
Custom reward addresses are one of the core features needed for
proper masternode vaults.  With them implemented now, we can update
the mnvaults.py test (resolving two FIXME's in there) to actually make
use of an explicit reward address so that the masternode rewards are
received and not lost (as we want them to be in practice).
This defines a new time-activated "fork", Fork::CustomRewardAddresses.
For now, it is scheduled at timestamp 2000000000; that will be set to
the actual activation time once it is determined.

When this fork becomes active (i.e. the current best block's timestamp
goes beyond the activation time), we require peers to use the new protocol
version that supports custom reward addresses.  The fork has no other
(in particular, no consensus-level) consequences.
This adds a new regtest, custom_address_update.py.  The test runs
two masternodes, where we explicitly set the protocol version of
one of the nodes to the "old" version not supporting custom reward
scripts for masternodes.

With this test, we ensure that all the masternode networking works fine
between "old" and "new" nodes before the update is activated, at least
as closely as we can without running a real old node.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant